package getOffer.offer15;

/**
 * @Author: wjy
 * @Date: 2021/11/15 9:15
 */
public class Solution {

    public static void main(String[] args) {
        int num = 11;
        Solution solution = new Solution();

        System.out.println(solution.hammingWeight(num));
    }

    public int hammingWeight(int n) {
        int j = 0;
        while (n != 0) {
            j += n & 1;
            // >>> 无符号位右移
            n = n >>> 1;
        }
        return j;
    }

}
